/*
 * Copyright (C) 2011 PickleMan <admin.aegamesi@gmail.com>
 * Copyright (C) 2011 IsmAvatar <IsmAvatar@gmail.com>
 * 
 * This file is part of Jeie.
 * Jeie is free software and comes with ABSOLUTELY NO WARRANTY.
 * See LICENSE for details.
 */

package org.jeie.gui.panels;

import java.awt.Dimension;
import java.awt.Rectangle;

import javax.swing.ButtonGroup;
import javax.swing.JPanel;
import javax.swing.JToggleButton;

import org.jeie.util.Util;

public class LinePanel extends JPanel {
	private static final long serialVersionUID = 939817877255023658L;

	private JToggleButton line1;
	private JToggleButton line2;
	private JToggleButton line3;
	private JToggleButton line5;
	private JToggleButton line8;
	private ButtonGroup lineGroup;

	//1, 2, 3, 5, 8
	public LinePanel() {
		setPreferredSize(new Dimension(48, 80));
		setLayout(null);

		line1 = new JToggleButton(Util.getIconForKey("LinePanel.LINE1")); //$NON-NLS-1$
		line2 = new JToggleButton(Util.getIconForKey("LinePanel.LINE2")); //$NON-NLS-1$
		line3 = new JToggleButton(Util.getIconForKey("LinePanel.LINE3")); //$NON-NLS-1$
		line5 = new JToggleButton(Util.getIconForKey("LinePanel.LINE5")); //$NON-NLS-1$
		line8 = new JToggleButton(Util.getIconForKey("LinePanel.LINE8")); //$NON-NLS-1$

		line1.setBounds(new Rectangle(0, 0, 48, 16));
		line2.setBounds(new Rectangle(0, 16, 48, 16));
		line3.setBounds(new Rectangle(0, 32, 48, 16));
		line5.setBounds(new Rectangle(0, 48, 48, 16));
		line8.setBounds(new Rectangle(0, 64, 48, 16));

		lineGroup = new ButtonGroup();
		lineGroup.add(line1);
		lineGroup.add(line2);
		lineGroup.add(line3);
		lineGroup.add(line5);
		lineGroup.add(line8);

		add(line1);
		add(line2);
		add(line3);
		add(line5);
		add(line8);

		line1.setSelected(true);
	}

	public int getLineSize() {
		if (line1.isSelected())
			return 1;
		if (line2.isSelected())
			return 2;
		if (line3.isSelected())
			return 3;
		if (line5.isSelected())
			return 5;
		if (line8.isSelected())
			return 8;
		return 1;
	}
}
